package com.example.myapplication.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.myapplication.R;

public class Main2Activity3 extends AppCompatActivity {

    private ImageView touxiang;
    private TextView shui;
    private Button button;
    private TextView shui2;
    String own;
    private ImageView m23Back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main23);
        initView();
      changes();
    }
    /*
    根据谁赢了更换图片
     */
    public void changes(){
        own = getIntent().getStringExtra("own");
        if (own.equals("路飞赢了")) {
            touxiang.setImageResource(R.drawable.lufei);
        }
        if (own.equals("女帝赢了")) {
            touxiang.setImageResource(R.drawable.nudi);
        }
        if (own.equals("平局")) {
            touxiang.setImageResource(R.drawable.hhh);
        }
        shui.setText(own);
        shui2.setText(own);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(Main2Activity3.this, Main2Activity.class));
                finish();
            }
        });
    }
/*
初始化控件
 */
    private void initView() {
        touxiang = (ImageView) findViewById(R.id.touxiang);
        shui = (TextView) findViewById(R.id.shui);
        button = (Button) findViewById(R.id.button);
        shui2 = (TextView) findViewById(R.id.shui2);
        m23Back = (ImageView) findViewById(R.id.m23_back);
        m23Back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
